import {
  AllowNull,
  AutoIncrement,
  Column,
  DataType,
  ForeignKey,
  Model,
  PrimaryKey,
  Table,
} from 'sequelize-typescript';
import { Content } from './content.model';

@Table({
  tableName: 'entry_list',
})
export class Entry extends Model {
  @PrimaryKey
  @AutoIncrement
  @Column({
    type: DataType.INTEGER,
    allowNull: false,
    comment: 'entry_id',
  })
  id: string;

  @ForeignKey(() => Content)
  @AllowNull(false)
  @Column({ type: DataType.INTEGER, comment: '' })
  contentId: number;

  //用户id
  @Column({
    type: DataType.INTEGER,
    comment: 'userId',
  })
  userId: number;

  @Column({
    type: DataType.TEXT('long'),
    comment: '',
  })
  description: string;

  @Column({
    type: DataType.JSON,
    comment: '',
  })
  startDate: JSON;

  @Column({
    type: DataType.JSON,
    comment: '',
  })
  endDate: JSON;

  @Column({
    type: DataType.STRING(255),
    comment: '',
  })
  title: string;

  @Column({
    type: DataType.STRING(255),
    comment: '',
  })
  subTitle: string;

  @Column({
    type: DataType.INTEGER,
    comment: '',
  })
  educationBackground: number;

  @Column({
    type: DataType.INTEGER,
    defaultValue: 0,
    comment: '排序',
  })
  order: number;

  @Column({
    type: DataType.BOOLEAN,
    defaultValue: false,
    comment: '',
  })
  isHidden: boolean;

  @Column({
    type: DataType.JSON,
    defaultValue: null,
    comment: '',
  })
  list: JSON;
}
